from concurrent.futures import ThreadPoolExecutor, wait

import requests


def test():
    url = "http://localhost:8000/ocr/base64"
    headers = {
        "accept": "application/json",
        "Content-Type": "application/x-www-form-urlencoded"
    }
    base64_image = ""

    try:
        response = requests.post(url, headers=headers, data={"base64_image": base64_image})

        print("响应状态码:", response.status_code)
        print("响应内容:", response.json())  # 如果返回JSON格式
    except Exception as e:
        print("请求出错:", str(e))


def main():
    tasks = []
    with ThreadPoolExecutor(max_workers=10) as executor:
        for _ in range(100):
            future = executor.submit(test)
            tasks.append(future)
    wait(tasks)
    print("所有任务完成")


if __name__ == "__main__":
    main()
